#ifndef _SCENECTRL_H_
#define _SCENECTRL_H_

#include "2d/CCScene.h"
#include "qobject.h"
#include "Common.h"
//#include"cocos-ext.h"
//USING_NS_CC_EXT;
USING_NS_CC;
class WindowBox;
class NewItemData;
class NodeInfo;

class SceneCtrl : public QObject, public Scene/*, public ScrollViewDelegate*/
{
	Q_OBJECT

public:
	SceneCtrl();
	~SceneCtrl();

	void mouseMoveEvent(float x, float y);
	void mousePressEvent(float x, float y);
	void mouseReleaseEvent(float x, float y);

	Node* getUiRoot();
	void setUiRoot(Node* node);
	WindowBox* getBox() { return _boxesNode; }

	void onResize(float frameWidth, float frameHeight);
	bool init(float frameWidth, float frameHeight);
	static SceneCtrl* create(float frameWidth, float frameHeight);

	std::string getNodeType(Node* node);
private:
	const char* csbName() const { return "res/HelloLayer.csb"; }
	//virtual void onEnter();
signals:
	void selectedBox();

public slots:
	void setCurrentNode(Node*);
	void registerNode(NodeInfo* info);
	void receivePlist(const QString& strfilename);
//private:
	//virtual void scrollViewDidScroll(ScrollView* view)override;
	//virtual void scrollViewDidZoom(ScrollView* view)override;
	//virtual void scrollViewMoveOver(ScrollView* view)override;
private:

	int _hoveredResizePoint;
	bool _isMouseHoveredBox;
	bool _mousePressed;

	float _lastx;
	float _lasty;

	Node* _rootNode;
	WindowBox* _boxesNode;
	std::map<Node*, std::string> _nodeTypeMapping;
	std::list<Node*> m_listnode;
};

#endif//_SCENECTRL_H_